package com.ia.aistream.rest;

import com.ia.aistream.AiAdminApplicationTest;
import com.ia.aistream.manager.operating.util.visio.PdfToPngUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

/**
 * Author: xiaoyu
 * Date: 2020/12/29 14:17
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = AiAdminApplicationTest.class)
public class RestDemo {

    @Autowired
    private RestTemplate restTemplate;

//    @Test
//    public void test1(){
//        MultiValueMap<String,Object> paramMap = new LinkedMultiValueMap<>();
//        paramMap.add("filePath","小明");
//        paramMap.add("fileName",111);
//        paramMap.add("width",18);
//        paramMap.add("height",18);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON);
//        HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(paramMap, headers);
//        String response = restTemplate.postForObject("http://localhost:5000/cad/dxfToPng",request,String.class);
//        //ResponseEntity<User> responseEntity = restTemplate.postForEntity("http://localhost:8181/aop/post/demo2",paramMap, User.class);
//        System.out.println(response);
//    }

    @Test
    public void test2(){
        CadDemo cadDemo = new CadDemo();
        cadDemo.setFilePath("D:\\迅捷File\\dwg1\\");
        cadDemo.setFileName("FQ1-ASG-LC-003_辅助给水系统流程图（三）001_02.dwg");
        cadDemo.setHeight(0L);
        cadDemo.setWidth(0L);
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity request = new HttpEntity<>(cadDemo, headers);
        ResponseEntity<ResDemo> responseEntity = restTemplate.postForEntity("http://localhost:5000/cad/dwgToPng",request, ResDemo.class);
        System.out.println(responseEntity.getBody());
    }


    @Test
    public void test3() throws Exception {
        String visioName = "D:/a/jk.vsd";
        PdfToPngUtil.visioToPng(visioName);
    }

}
